/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cip.esymons.general.bc;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.general.be.Solicitante;

/**
 *
 * @author OscarA
 */
public class SolicitanteDelegate {

    SolicitanteFacadeLocal local;

    public SolicitanteDelegate() {
        local = lookupSolicitanteFacade();
    }

    public Solicitante buscarSolicitante(Long solCodigo) throws Exception{
        return local.find(solCodigo);
    }

    public Long buscarxRuc(String ruc) throws Exception {
        return local.buscarxRuc(ruc);
    }

    private SolicitanteFacadeLocal lookupSolicitanteFacade() {
        try {
            Context c = new InitialContext();
            return (SolicitanteFacadeLocal) c.lookup("java:comp/env/SolicitanteFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public void registrar(Solicitante sol) {
        try {
            local.create(sol);
        } catch (Exception e) {
        }
    }
}
